#ifndef ABBREVIATIONS_H_INCLUDED
#define ABBREVIATIONS_H_INCLUDED

#include <wx/wxprec.h>
#include <M_Code_plugin.h>

WX_DECLARE_STRING_HASH_MAP( wxString, AutoCompleteMap );
WX_DECLARE_STRING_HASH_MAP( AutoCompleteMap*, AutoCompLanguageMap );

extern wxString defaultLanguageStr;

class Abbreviations : public M_Code_Plugin {
  public:
    Abbreviations();
    virtual ~Abbreviations();
    virtual int GetConfigurationPriority() const { return 50; }
    virtual int GetConfigurationGroup() const { return cgEditor; }
    virtual cbConfigurationPanel* GetConfigurationPanel( wxWindow* parent );
  protected:
    virtual void OnAttach();
    virtual void OnRelease( bool appShutDown );
  public:
    static void AutoComplete( M_Code_Editor& ed );
    static void ExchangeTabAndSpaces( AutoCompleteMap& map );
  private:
    static Abbreviations* Get() { return m_Singleton; }
    void DoAutoComplete( M_Code_Editor* ed );
    static Abbreviations* m_Singleton;
    void RegisterScripting();
    void UnregisterScripting();
    void LoadAutoCompleteConfig();
    void SaveAutoCompleteConfig();
    void ClearAutoCompLanguageMap();
    AutoCompleteMap* GetCurrentACMap( M_Code_Editor* ed );
  private:
    void OnEditAutoComplete( M_Code_unused wxCommandEvent& event );
    void OnEditMenuUpdateUI( wxUpdateUIEvent& event );
  public:
    void EditorEventHook( M_Code_Editor* editor, wxScintillaEvent& event );
  private:
    friend class AbbreviationsConfigPanel;
    AutoCompLanguageMap m_AutoCompLanguageMap;
    int m_EditorHookId;
    bool m_IsAutoCompVisible;
  private:
    DECLARE_EVENT_TABLE();
};

#endif
